
<!doctype html>
<html lang="en" class="no-js">
  <head>
    
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1">
      
      
      
      <link rel="icon" href="../../../../static/images/favicon.png">
      <meta name="generator" content="mkdocs-1.3.0, mkdocs-material-8.2.8">
    
    
      
        <title>生产环境阿里 EMR(Hbase1.2+Phoenix4.10)夸集群数据迁移采坑实录 - WL4G DOCS</title>
      
    
    
      <link rel="stylesheet" href="../../../../assets/stylesheets/main.644de097.min.css">
      
        
        <link rel="stylesheet" href="../../../../assets/stylesheets/palette.e6a45f82.min.css">
        
      
    
    
    
      
        
        
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
        <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
      
    
    
      <link rel="stylesheet" href="../../../../static/css/util.css">
    
    <script>__md_scope=new URL("../../../..",location),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
    
      

    
    
  </head>
  
  
    
    
      
    
    
    
    
    <body dir="ltr" data-md-color-scheme="default" data-md-color-primary="" data-md-color-accent="">
  
    
    
      <script>var palette=__md_get("__palette");if(palette&&"object"==typeof palette.color)for(var key of Object.keys(palette.color))document.body.setAttribute("data-md-color-"+key,palette.color[key])</script>
    
    <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
    <label class="md-overlay" for="__drawer"></label>
    <div data-md-component="skip">
      
        
        <a href="#emrhbase12phoenix410" class="md-skip">
          Skip to content
        </a>
      
    </div>
    <div data-md-component="announce">
      
    </div>
    
      <div data-md-component="outdated" hidden>
        <aside class="md-banner md-banner--warning">
          
        </aside>
      </div>
    
    
      

<header class="md-header" data-md-component="header">
  <nav class="md-header__inner md-grid" aria-label="Header">
    <a href="../../../.." title="WL4G DOCS" class="md-header__button md-logo" aria-label="WL4G DOCS" data-md-component="logo">
      
  <img src="../../../../static/images/mylogo.jpeg" alt="logo">

    </a>
    <label class="md-header__button md-icon" for="__drawer">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2z"/></svg>
    </label>
    <div class="md-header__title" data-md-component="header-title">
      <div class="md-header__ellipsis">
        <div class="md-header__topic">
          <span class="md-ellipsis">
            WL4G DOCS
          </span>
        </div>
        <div class="md-header__topic" data-md-component="header-topic">
          <span class="md-ellipsis">
            
              生产环境阿里 EMR(Hbase1.2+Phoenix4.10)夸集群数据迁移采坑实录
            
          </span>
        </div>
      </div>
    </div>
    
      <form class="md-header__option" data-md-component="palette">
        
          
          
          <input class="md-option" data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme="default" data-md-color-primary="" data-md-color-accent=""  aria-label="Switch to dark mode"  type="radio" name="__palette" id="__palette_1">
          
            <label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_2" hidden>
              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17 6H7c-3.31 0-6 2.69-6 6s2.69 6 6 6h10c3.31 0 6-2.69 6-6s-2.69-6-6-6zm0 10H7c-2.21 0-4-1.79-4-4s1.79-4 4-4h10c2.21 0 4 1.79 4 4s-1.79 4-4 4zM7 9c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/></svg>
            </label>
          
        
          
          
          <input class="md-option" data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme="slate" data-md-color-primary="" data-md-color-accent=""  aria-label="Switch to light mode"  type="radio" name="__palette" id="__palette_2">
          
            <label class="md-header__button md-icon" title="Switch to light mode" for="__palette_1" hidden>
              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17 7H7a5 5 0 0 0-5 5 5 5 0 0 0 5 5h10a5 5 0 0 0 5-5 5 5 0 0 0-5-5m0 8a3 3 0 0 1-3-3 3 3 0 0 1 3-3 3 3 0 0 1 3 3 3 3 0 0 1-3 3z"/></svg>
            </label>
          
        
      </form>
    
    
      <div class="md-header__option">
        <div class="md-select">
          
          <button class="md-header__button md-icon" aria-label="Select language">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m12.87 15.07-2.54-2.51.03-.03A17.52 17.52 0 0 0 14.07 6H17V4h-7V2H8v2H1v2h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04M18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12m-2.62 7 1.62-4.33L19.12 17h-3.24z"/></svg>
          </button>
          <div class="md-select__inner">
            <ul class="md-select__list">
              
                <li class="md-select__item">
                  <a href="/en/" hreflang="en" class="md-select__link">
                    English
                  </a>
                </li>
                
                <li class="md-select__item">
                  <a href="/zh/" hreflang="zh" class="md-select__link">
                    简体中文
                  </a>
                </li>
                
            </ul>
          </div>
        </div>
      </div>
    
    
      <label class="md-header__button md-icon" for="__search">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg>
      </label>
      <div class="md-search" data-md-component="search" role="dialog">
  <label class="md-search__overlay" for="__search"></label>
  <div class="md-search__inner" role="search">
    <form class="md-search__form" name="search">
      <input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
      <label class="md-search__icon md-icon" for="__search">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg>
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg>
      </label>
      <nav class="md-search__options" aria-label="Search">
        
        <button type="reset" class="md-search__icon md-icon" aria-label="Clear" tabindex="-1">
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"/></svg>
        </button>
      </nav>
      
        <div class="md-search__suggest" data-md-component="search-suggest"></div>
      
    </form>
    <div class="md-search__output">
      <div class="md-search__scrollwrap" data-md-scrollfix>
        <div class="md-search-result" data-md-component="search-result">
          <div class="md-search-result__meta">
            Initializing search
          </div>
          <ol class="md-search-result__list"></ol>
        </div>
      </div>
    </div>
  </div>
</div>
    
    
  </nav>
  
</header>
    
    <div class="md-container" data-md-component="container">
      
      
        
          
            
<nav class="md-tabs" aria-label="Tabs" data-md-component="tabs">
  <div class="md-tabs__inner md-grid">
    <ul class="md-tabs__list">
      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../../.." class="md-tabs__link">
        Getting Started
      </a>
    </li>
  

      
    </ul>
  </div>
</nav>
          
        
      
      <main class="md-main" data-md-component="main">
        <div class="md-main__inner md-grid">
          
            
              
              <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

  


  

<nav class="md-nav md-nav--primary md-nav--lifted md-nav--integrated" aria-label="Navigation" data-md-level="0">
  <label class="md-nav__title" for="__drawer">
    <a href="../../../.." title="WL4G DOCS" class="md-nav__button md-logo" aria-label="WL4G DOCS" data-md-component="logo">
      
  <img src="../../../../static/images/mylogo.jpeg" alt="logo">

    </a>
    WL4G DOCS
  </label>
  
  <ul class="md-nav__list" data-md-scrollfix>
    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle" data-md-toggle="__nav_1" data-md-state="indeterminate" type="checkbox" id="__nav_1" checked>
      
      
      
      
        <label class="md-nav__link" for="__nav_1">
          Getting Started
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" aria-label="Getting Started" data-md-level="1">
        <label class="md-nav__title" for="__nav_1">
          <span class="md-nav__icon md-icon"></span>
          Getting Started
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../.." class="md-nav__link">
        Introduction
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../ABOUT_CN/" class="md-nav__link">
        About
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
  </ul>
</nav>
                  </div>
                </div>
              </div>
            
            
          
          <div class="md-content" data-md-component="content">
            <article class="md-content__inner md-typeset">
              
                


<h1 id="emrhbase12phoenix410">生产环境阿里 EMR(Hbase1.2+Phoenix4.10)夸集群数据迁移采坑实录<a class="headerlink" href="#emrhbase12phoenix410" title="Permanent link">&para;</a></h1>
<h2 id="1">1. 生产场景<a class="headerlink" href="#1" title="Permanent link">&para;</a></h2>
<blockquote>
<p>最近由于公司业务调整，新购了E-MapReduce集群，需将老E-MapReduce集群的数据迁移到新集群上（由于是iOT业务，又24小时实时写数据不中断）</p>
</blockquote>
<ul>
<li>Hbase(Phoenix)数据迁移方案主要分为：</li>
<li>Hadoop层面(<code>distcp</code>)</li>
<li>Hbase层面(<code>copyTable</code>、<code>export/import</code>、<code>snapshot</code>)</li>
</ul>
<h2 id="2-distcp-emr">2. 以下针对 <code>distcp</code> 方案详细说明(以亲测阿里EMR为例)<a class="headerlink" href="#2-distcp-emr" title="Permanent link">&para;</a></h2>
<h3 id="21-tmpecs">2.1 首先打通两个集群网络(建议内网)，新建一个tmp安全组，将两个集群的所有ECS都加入进来<a class="headerlink" href="#21-tmpecs" title="Permanent link">&para;</a></h3>
<h3 id="22-cluster-ahbasehdfsdistcpcluster-bhbasehdfshdfs">2.2 Cluster-A中将HBase的表在HDFS存储文件distcp到Cluster-B的HBase在HDFS中对应的目录(一定要用hdfs账户)<a class="headerlink" href="#22-cluster-ahbasehdfsdistcpcluster-bhbasehdfshdfs" title="Permanent link">&para;</a></h3>
<div class="highlight"><pre><span></span><code><a id="__codelineno-0-1" name="__codelineno-0-1"></a><a href="#__codelineno-0-1"><span class="linenos" data-linenos="1 "></span></a><span class="o">[</span>root@emr-header-1 ~<span class="o">]</span><span class="c1"># sudo su hdfs</span>
<a id="__codelineno-0-2" name="__codelineno-0-2"></a><a href="#__codelineno-0-2"><span class="linenos" data-linenos="2 "></span></a><span class="c1"># 将表 safeclound.tb_ammeter 从A集群在线拷贝到B集群, 注: 老版本hdfs默认端口是9000新版本是8020</span>
<a id="__codelineno-0-3" name="__codelineno-0-3"></a><a href="#__codelineno-0-3"><span class="linenos" data-linenos="3 "></span></a><span class="o">[</span>hdfs@emr-header-1 ~<span class="o">]</span><span class="c1"># hadoop distcp hdfs://ClusterA:8020/hbase/data/default/safeclound.tb_ammeter hdfs://ClusterB:8020/hbase/data/default</span>
</code></pre></div>
<blockquote>
<p><strong>注:</strong> <code>/hbase/data/default</code> 是 <code>Hbase</code> 表在 <code>Hdfs</code> 存储路径，例如表<code>sc.tb_test1</code>的存储路径是<code>/hbase/data/default/sc.tb_test1</code>, 可以只有单个表的路径，也可以是default下面所有表的路径(即*表示)，EMR的老版本 <code>Hdfs</code> 端口是 <code>9000</code>，新版<code>hdfs</code>端口是<code>8020</code>，这个具体情况而定就行。</p>
<p><strong>特别注意:</strong> 千万不要把 <code>Hbase</code> 和 <code>Phoenix</code> 的系统表拷贝了，只需拷贝自建的业务表即可(因为distcp对于Cluster-B是覆盖操作)，为了安全起见及亲测经验还是老老实实一张一张表拷贝吧，非常不建议使用 <code>*</code>，一是多个表数据量可能巨大，二是会把系统表拷贝过去了导致元数据出问题.</p>
</blockquote>
<p>Cluster-B中执行HBase repair修复(一定要用hbase账户)</p>
<div class="highlight"><pre><span></span><code><a id="__codelineno-1-1" name="__codelineno-1-1"></a><a href="#__codelineno-1-1"><span class="linenos" data-linenos="1 "></span></a><span class="o">[</span>root@emr-header-1 ~<span class="o">]</span><span class="c1"># sudo su hbase</span>
<a id="__codelineno-1-2" name="__codelineno-1-2"></a><a href="#__codelineno-1-2"><span class="linenos" data-linenos="2 "></span></a><span class="o">[</span>hbase@emr-header-1 ~<span class="o">]</span><span class="c1"># hbase hbck -repair # 执行hbase恢复命令, 让hbase引用distcp过来的hdfs表文件,重建 meta</span>
<a id="__codelineno-1-3" name="__codelineno-1-3"></a><a href="#__codelineno-1-3"><span class="linenos" data-linenos="3 "></span></a><span class="o">[</span>hbase@emr-header-1 ~<span class="o">]</span><span class="c1"># hbase shell # 进入shell检查是否迁移成功</span>
<a id="__codelineno-1-4" name="__codelineno-1-4"></a><a href="#__codelineno-1-4"><span class="linenos" data-linenos="4 "></span></a>...
<a id="__codelineno-1-5" name="__codelineno-1-5"></a><a href="#__codelineno-1-5"><span class="linenos" data-linenos="5 "></span></a>hbase<span class="o">(</span>main<span class="o">)</span>:001:0&gt; list <span class="c1"># 列出当前所有表</span>
<a id="__codelineno-1-6" name="__codelineno-1-6"></a><a href="#__codelineno-1-6"><span class="linenos" data-linenos="6 "></span></a>hbase<span class="o">(</span>main<span class="o">)</span>:001:0&gt; scan <span class="s1">&#39;safeclound.tb_ammeter&#39;</span>, <span class="o">{</span><span class="nv">LIMIT</span> <span class="o">=</span>&gt; <span class="m">10</span><span class="o">}</span> <span class="c1"># 扫描表前10条数据</span>
</code></pre></div>
<blockquote>
<p><strong>注:</strong> 根据亲测经验，如果执行 <code>hbase hbck -repair</code> 后在 <code>hbase shell</code> 中任然看不到迁移来的表，别急，先喝杯茶稍等一会儿（内网迁移通常 1~2 分钟内看数据量）然后再重新执行 <code>hbase hbck -repair</code> 命令，直到出现以下字幕，说明 Hbase 迁移就要成功了...</p>
</blockquote>
<div class="highlight"><pre><span></span><code><a id="__codelineno-2-1" name="__codelineno-2-1"></a><a href="#__codelineno-2-1"><span class="linenos" data-linenos="1 "></span></a>util.HBaseFsck: Sleeping 10000ms before re-checking after fix...
</code></pre></div>
<blockquote>
<p>猜测此问题可能是由于hdfs拷贝过来后有些异步操作未完成所导致?</p>
</blockquote>
<h3 id="23-phoenix-hbase">2.3 (若不是 Phoenix + Hbase 架构组合可忽略)<a class="headerlink" href="#23-phoenix-hbase" title="Permanent link">&para;</a></h3>
<p>在上一步hbase shell检查迁移成功之后，再测试Phoenix查询，可能会出现在hbase shell中 <code>list</code> 或者 <code>scan</code> 命令都完全正常，但在Phoenix中看不到迁移过来的表，别急，因为 Phoenix 还不知道你从 hdfs 迁移的表，经过Google找到解决方法1：</p>
<ul>
<li>方案1: 通过在 Phoenix 执行 <code>create view ...</code> 语句，创建一个视图就可以了（但后续还要维护视图，如果不像创建view 可参考以下2方案）</li>
<li>方案2: 直接在 Phoenix 执行 <code>create table ...</code> 语句，(警告: 如果集群数据量过大，此方式可能会出现 Huang 住最后导致 Hbase 某个节点宕机, 亲身经历, 非万不得已不推荐使用！)</li>
<li>方案3: 但也不是没有 <code>"优雅"</code> 的办法, 防止方案2宕机, 亲测还有一个巧妙的 <code>"玄学"</code> 办法: 在执行 <code>create table</code> 时无需等待执行完成，当按下Enter键执行后, 过1秒后立即 <code>Ctrl+C</code> 终止 <code>sqlline.py</code> 进程, 然后重新打开 <code>sqlline.py</code>, 执行 <code>!table</code> 命令就可以看到新迁移的表了 (警告: 非万不得已不推荐使用！)</li>
</ul>
<h2 id="2-faq">2. FAQ<a class="headerlink" href="#2-faq" title="Permanent link">&para;</a></h2>
<h3 id="21-clusterb">2.1. 不小心误覆盖了 ClusterB 的系统表如何恢复？<a class="headerlink" href="#21-clusterb" title="Permanent link">&para;</a></h3>
<ul>
<li>step1) 首先备份 Hbase 在 Hdfs 上的根目录</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-3-1" name="__codelineno-3-1"></a><a href="#__codelineno-3-1"><span class="linenos" data-linenos="1 "></span></a><span class="o">[</span>root@emr-header-1 ~<span class="o">]</span><span class="c1"># hdfs dfs -mv /hbase /hbase_bak</span>
</code></pre></div>
<ul>
<li>step2) 停掉 Hbase 所有服务（若 EMR 新版，可在阿里 EMR 控制台 <code>Stop Hbase ALL</code>）</li>
<li>step3) 清除 ZK 里 Hbase 的注册信息（很关键，否则不会自动生成系统表）</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-4-1" name="__codelineno-4-1"></a><a href="#__codelineno-4-1"><span class="linenos" data-linenos="1 "></span></a><span class="o">[</span>root@emr-header-1 ~<span class="o">]</span><span class="c1"># ./zkCli.sh -server localhost:2181</span>
<a id="__codelineno-4-2" name="__codelineno-4-2"></a><a href="#__codelineno-4-2"><span class="linenos" data-linenos="2 "></span></a><span class="o">[</span>zk: localhost:2181<span class="o">(</span>CONNECTED<span class="o">)</span> <span class="m">1</span><span class="o">]</span> ls /
<a id="__codelineno-4-3" name="__codelineno-4-3"></a><a href="#__codelineno-4-3"><span class="linenos" data-linenos="3 "></span></a><span class="o">[</span>zk: localhost:2181<span class="o">(</span>CONNECTED<span class="o">)</span> <span class="m">1</span><span class="o">]</span> rmr /hbase
</code></pre></div>
<ul>
<li>step4) 重新启动hbase所有服务</li>
<li>step5) 测试hbase是否自动生成</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-5-1" name="__codelineno-5-1"></a><a href="#__codelineno-5-1"><span class="linenos" data-linenos=" 1 "></span></a><span class="o">[</span>root@emr-header-1 ~<span class="o">]</span><span class="c1"># hdfs dfs -ls / # 查看hdfs里是否重新生成了/hbase目录</span>
<a id="__codelineno-5-2" name="__codelineno-5-2"></a><a href="#__codelineno-5-2"><span class="linenos" data-linenos=" 2 "></span></a><span class="o">[</span>root@emr-header-1 ~<span class="o">]</span><span class="c1"># hbase shell</span>
<a id="__codelineno-5-3" name="__codelineno-5-3"></a><a href="#__codelineno-5-3"><span class="linenos" data-linenos=" 3 "></span></a>hbase<span class="o">(</span>main<span class="o">)</span>:001:0&gt; list <span class="c1"># 再查看 hbase 里是否可见相应的系统表</span>
<a id="__codelineno-5-4" name="__codelineno-5-4"></a><a href="#__codelineno-5-4"><span class="linenos" data-linenos=" 4 "></span></a>
<a id="__codelineno-5-5" name="__codelineno-5-5"></a><a href="#__codelineno-5-5"><span class="linenos" data-linenos=" 5 "></span></a>TABLE
<a id="__codelineno-5-6" name="__codelineno-5-6"></a><a href="#__codelineno-5-6"><span class="linenos" data-linenos=" 6 "></span></a>SYSTEM.CATALOG
<a id="__codelineno-5-7" name="__codelineno-5-7"></a><a href="#__codelineno-5-7"><span class="linenos" data-linenos=" 7 "></span></a>SYSTEM.FUNCTION
<a id="__codelineno-5-8" name="__codelineno-5-8"></a><a href="#__codelineno-5-8"><span class="linenos" data-linenos=" 8 "></span></a>SYSTEM.MUTEX
<a id="__codelineno-5-9" name="__codelineno-5-9"></a><a href="#__codelineno-5-9"><span class="linenos" data-linenos=" 9 "></span></a>SYSTEM.SEQUENCE
<a id="__codelineno-5-10" name="__codelineno-5-10"></a><a href="#__codelineno-5-10"><span class="linenos" data-linenos="10 "></span></a>SYSTEM.STATS
<a id="__codelineno-5-11" name="__codelineno-5-11"></a><a href="#__codelineno-5-11"><span class="linenos" data-linenos="11 "></span></a><span class="m">5</span> row<span class="o">(</span>s<span class="o">)</span> <span class="k">in</span> <span class="m">0</span>.1010 seconds
<a id="__codelineno-5-12" name="__codelineno-5-12"></a><a href="#__codelineno-5-12"><span class="linenos" data-linenos="12 "></span></a>...
</code></pre></div>
<p>恭喜，出现以上字幕即恢复成功！</p>
<h3 id="22">2.2. 如何使用离线拷贝 ？<a class="headerlink" href="#22" title="Permanent link">&para;</a></h3>
<ul>
<li>step1) 只需将 <code>distcp</code> 命令改用 <code>get</code>、<code>put</code> 通过本地中转就行了(无关心执行账户)</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-6-1" name="__codelineno-6-1"></a><a href="#__codelineno-6-1"><span class="linenos" data-linenos="1 "></span></a><span class="c1">#从源hbase集群下载业务表到本地</span>
<a id="__codelineno-6-2" name="__codelineno-6-2"></a><a href="#__codelineno-6-2"><span class="linenos" data-linenos="2 "></span></a><span class="o">[</span>root@emr-header-1 ~<span class="o">]</span>$ hdfs dfs -get /hbase/data/default/safeclound.tb_ammeter_analyze
</code></pre></div>
<ul>
<li>step2) scp 到目地 Hbase 集群服务器</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-7-1" name="__codelineno-7-1"></a><a href="#__codelineno-7-1"><span class="linenos" data-linenos="1 "></span></a><span class="o">[</span>root@emr-header-1 ~<span class="o">]</span>$ tar -cvf safeclound.tb_ammeter_analyze.tar safeclound.tb_ammeter_analyze
<a id="__codelineno-7-2" name="__codelineno-7-2"></a><a href="#__codelineno-7-2"><span class="linenos" data-linenos="2 "></span></a><span class="o">[</span>root@emr-header-1 ~<span class="o">]</span>$ scp safeclound.tb_ammeter_analyze.tar root@emr-header-1:/root
</code></pre></div>
<ul>
<li>step3) 在目地服务器上将业务表文件加载到 Hdfs(其中emr-header-1安装的是原生Hbase且是默认配置，因此在Hdfs的数据文件路径才是: <code>/tmp/hbase-root/hbase/data/default/</code></li>
</ul>
<p>，如果是阿里云的EMR，则在hdfs的数据路径为：/hbase/data/default）</p>
<div class="highlight"><pre><span></span><code><a id="__codelineno-8-1" name="__codelineno-8-1"></a><a href="#__codelineno-8-1"><span class="linenos" data-linenos="1 "></span></a><span class="o">[</span>root@emr-header-1 ~<span class="o">]</span><span class="c1"># hdfs dfs -put /root/safeclound.tb_ammeter_analyze/ /tmp/hbase-root/hbase/data/default/</span>
</code></pre></div>
<ul>
<li>step4) 查看验证是否加载成功</li>
</ul>
<div class="highlight"><pre><span></span><code><a id="__codelineno-9-1" name="__codelineno-9-1"></a><a href="#__codelineno-9-1"><span class="linenos" data-linenos="1 "></span></a><span class="o">[</span>root@emr-header-1 ~<span class="o">]</span><span class="c1"># hadoop fs -ls /tmp/hbase-root/hbase/data/default/</span>
</code></pre></div>
<ul>
<li>step5) 接下来在新集群 ClusterB 中执行 <code>hbase hbck -repair</code> 修复命令, 操作过程同上...</li>
</ul>
<h3 id="23-phoenixhbase-phoenix-47-410-hbase-shell-scan">2.3 若使用的是 <code>Phoenix+Hbase</code> 组合，若 <code>Phoenix</code> 从 <code>4.7</code> 升级到 <code>4.10</code>之后，可能会出现除主键字段外其他字段都查不出数据，但在 <code>hbase shell</code> 中 <code>scan</code> 表又有数据, 这种情况如何处理？<a class="headerlink" href="#23-phoenixhbase-phoenix-47-410-hbase-shell-scan" title="Permanent link">&para;</a></h3>
<p><a href="http://phoenix.apache.org/columnencoding.html">参考 Phoenix 官网资料: http://phoenix.apache.org/columnencoding.html</a></p>
<p><img alt="phoenix官网截图" src="https://blogs.wl4g.com:443/wp-content/uploads/2021/07/p111-300x147.png" /></p>
<h2 id="_1">其他参考文献<a class="headerlink" href="#_1" title="Permanent link">&para;</a></h2>
<ul>
<li>
<ol>
<li><a href="https://www.cnblogs.com/ballwql/p/hbase_data_transfer.html">hbase 数据迁移介绍</a></li>
</ol>
</li>
<li>
<ol>
<li><a href="https://developer.aliyun.com/article/70469">hbase 数据迁移之 distcp</a></li>
</ol>
</li>
</ul>

              
            </article>
          </div>
        </div>
        
      </main>
      
        <footer class="md-footer">
  
  <div class="md-footer-meta md-typeset">
    <div class="md-footer-meta__inner md-grid">
      <div class="md-copyright">
  
  
    Made with
    <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
      Material for MkDocs
    </a>
  
</div>
      
    </div>
  </div>
</footer>
      
    </div>
    <div class="md-dialog" data-md-component="dialog">
      <div class="md-dialog__inner md-typeset"></div>
    </div>
    <script id="__config" type="application/json">{"base": "../../../..", "features": ["search.suggest", "search.highlight", "navigation.tabs", "navigation.expand", "toc.follow", "toc.integrate"], "search": "../../../../assets/javascripts/workers/search.5e67fbfe.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.config.lang": "en", "search.config.pipeline": "trimmer, stopWordFilter", "search.config.separator": "[\\s\\-]+", "search.placeholder": "Search", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version.title": "Select version"}, "version": {"default": "latest", "provider": "mike"}}</script>
    
    
      <script src="../../../../assets/javascripts/bundle.c44cc438.min.js"></script>
      
        <script src="../../../../static/js/util.js"></script>
      
    
  </body>
</html>